package com.yzycoc.hamster.demo.time202505.time20250521.test;

import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.core.util.IdUtil;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;

/**
 * hamster-demo
 *
 * @author Administrator
 * @since 2025/5/21 20:40
 **/
public class GenderInserSql {
    static String excelPath = "static/20250521/jhm.txt";

    public static void main(String[] args) {
        // 自定义参数
        String createName = "admin";
        String remark = "月卡密钥";
        int source = 1;
        String type = "yyf-month";
        String keyInfo = "游游蜂云手机月卡，请复制激活码到游游蜂APP中激活使用！";
        String keyUrl = "https://yzycoc.com/archives/yyf";
        String keyRemark = "游游蜂官网:https://vcphone.com/";
        List<String> keyList = getIds();
        System.out.println("长度" + keyList.size());
        for (String keyVal : keyList) {
            String uuid = IdUtil.simpleUUID();
            String sql = String.format(
                    "INSERT INTO `pay_key_cloud` (`uuid`, `create_name`, `remark`, `source`, `type`, `key_val`,`key_info`,`key_url`,`key_remark`, `status`) " +
                            "VALUES ('%s', '%s', '%s', %d, '%s', '%s','%s','%s','%s',  0);",
                    uuid, createName, remark, source, type, keyVal, keyInfo, keyUrl, keyRemark
            );
            System.out.println(sql);
        }
    }

    private static List<String> getIds() {
        // 读取类路径中的 JSON 文件
        ClassPathResource resource = new ClassPathResource(excelPath);
        // 读取为字符串（使用 UTF-8 编码）
        String jsonStr = resource.readStr(StandardCharsets.UTF_8);
        String[] split = jsonStr.split("\r\n");

        return Arrays.asList(split);
    }
}
